package components.direction;

public class Direction {

	public static Direction NORTH = new Direction(0, -1);
	public static Direction SOUTH = new Direction(0, 1);
	public static Direction WEST = new Direction(-1, 0);
	public static Direction EAST = new Direction(1, 0);
 	
	private int vx;
	private int vy;
	
	public Direction(int x, int y){
		this.setVx(x);
		this.setVy(y);
	}
	
	public Direction opposite(){
		return new Direction(this.getVx() *-1, this.getVy()*-1);
	}

	public int getVx() {
		return vx;
	}

	public void setVx(int vx) {
		this.vx = vx;
	}

	public int getVy() {
		return vy;
	}

	public void setVy(int vy) {
		this.vy = vy;
	}
	public String toString(){
		if (this.equals(EAST)){
			return "EAST";
		} else if (this.equals(NORTH)){
			return "NORTH";
		} else if (this.equals(WEST)){
			return "WEST";
		} else if (this.equals(SOUTH)){
			return "SOUTH";
		} else {
			return "[" + this.getVx() + "," + this.getVy() + "]";
		}
	}

	public Direction nextDir() {
		if (this.equals(NORTH)){
			return EAST;
		}else if (this.equals(EAST)){
			return SOUTH;
		}else if (this.equals(SOUTH)){
			return WEST;
		}else{
			return NORTH;
		}
			
	}
}
